<template>
  <div class="admin-index">
    <el-container>
      <!--            <el-aside width="auto">-->
      <!--                <div style="width:100%;height: 60px;display: flex;justify-content: center;align-items: center">-->
      <!--                    <h4>机构</h4>-->
      <!--                </div>-->
      <!--                <el-menu router default-active="1-4-1" class="el-menu-vertical-demo" @open="handleOpen"-->
      <!--                         @close="handleClose"-->
      <!--                         :collapse="isCollapse">-->
      <!--                    <el-menu-item index="/org/studentRegisterList">-->
      <!--                        <i class="el-icon-setting"></i>-->
      <!--                        <span slot="title">学员报名列表</span>-->
      <!--                    </el-menu-item>-->
      <!--                    &lt;!&ndash;                    <el-menu-item index="/org/orgList">&ndash;&gt;-->
      <!--                    &lt;!&ndash;                        <i class="el-icon-setting"></i>&ndash;&gt;-->
      <!--                    &lt;!&ndash;                        <span slot="title">机构列表</span>&ndash;&gt;-->
      <!--                    &lt;!&ndash;                    </el-menu-item>&ndash;&gt;-->
      <!--                    &lt;!&ndash;                    <el-menu-item index="/org/examTime">&ndash;&gt;-->
      <!--                    &lt;!&ndash;                        <i class="el-icon-setting"></i>&ndash;&gt;-->
      <!--                    &lt;!&ndash;                        <span slot="title">考试时间</span>&ndash;&gt;-->
      <!--                    &lt;!&ndash;                    </el-menu-item>&ndash;&gt;-->
      <!--                    &lt;!&ndash;                    <el-menu-item index="/org/studentScore">&ndash;&gt;-->
      <!--                    &lt;!&ndash;                        <i class="el-icon-setting"></i>&ndash;&gt;-->
      <!--                    &lt;!&ndash;                        <span slot="title">学员分数</span>&ndash;&gt;-->
      <!--                    &lt;!&ndash;                    </el-menu-item>&ndash;&gt;-->
      <!--                </el-menu>-->
      <!--            </el-aside>-->
      <el-container>
        <el-header>
          <el-dropdown class="user-name">
                          <span class="el-dropdown-link">
                            <span>机构管理端</span>：{{username}}
                              <i class="el-icon-arrow-down el-icon--right"></i>
                          </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item icon="el-icon-error" @click.native="close">退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          <!--                    <i :class="isCollapse? 'el-icon-s-unfold':'el-icon-s-fold'" @click="isCollapse = !isCollapse"></i>-->
          <div style="display: flex">
            <div>
              <img style="height: 30px;cursor: pointer;margin-top: 15px;" @click="toIndex" src="../../assets/logo/logo4.png">
            </div>
            <el-menu background-color="#F7F7F7" text-color="black" active-text-color="#409EFF" :default-active="$route.path" class="el-menu-demo" mode="horizontal" @select="handleSelect">
              <el-menu-item index="/org/studentRegisterList">
                <i class="el-icon-setting"></i>
                <span slot="title">学员档案列表</span>
              </el-menu-item>
            </el-menu>
            <!--                        <el-menu router :default-active="$route.path" class="el-menu-vertical-demo" @open="handleOpen"-->
            <!--                                           @close="handleClose" :collapse="isCollapse">-->
            <!--                        <el-menu-item index="/admin/studentRegisterList">-->
            <!--                            <span slot="title">学员待报名列表</span>-->
            <!--                        </el-menu-item>-->
            <!--                        <el-menu-item index="/admin/orgList">-->
            <!--                            <span slot="title">机构列表</span>-->
            <!--                        </el-menu-item>-->
            <!--                        <el-menu-item index="/admin/examTime">-->
            <!--                            <span slot="title">科目列表</span>-->
            <!--                        </el-menu-item>-->
            <!--                        <el-menu-item index="/admin/studentScore">-->
            <!--                            <span slot="title">报考记录</span>-->
            <!--                        </el-menu-item>-->
            <!--                    </el-menu>-->
          </div>
        </el-header>
        <el-main>
          <router-view :currentPage="currentPage" :pageSize="pageSize" @total="handleTotal"></router-view>
        </el-main>
        <el-footer>
          <div style="display: flex;align-items: center;width: 100%;justify-content: center">
            <span class="footer-content">Copyright © All Right By <a style="color: black;cursor: pointer;text-decoration: none" href="#">上海财才网信息科技有限公司</a></span>
          </div>
          <!--分页组件-->
          <!--                    <el-pagination-->
          <!--                            background-->
          <!--                            @size-change="handleSizeChange"-->
          <!--                            @current-change="handleCurrentChange"-->
          <!--                            :current-page="currentPage"-->
          <!--                            :page-sizes="[5, 10, 15, 20]"-->
          <!--                            :page-size="pageSize"-->
          <!--                            layout="total, sizes, prev, pager, next, jumper"-->
          <!--                            :total="total">-->
          <!--                    </el-pagination>-->
        </el-footer>
      </el-container>
    </el-container>
  </div>
</template>

<script>
  import Cookies from "js-cookie";
  import {getOrg} from "../../request/api";
  export default {
    name: "index",
    data() {
      return {
        isCollapse: true,
        //每页页数
        pageSize: 5,
        //当前页
        currentPage: 1,
        //总条数
        total:0,
        username:''
      };
    },
    methods: {
      toIndex(){
        this.$router.push('/org/studentRegisterList')
      },
      handleSelect(key,keypath){
        this.$router.push(key)
      },
      handleTotal(total){
        console.log('子传父',total);
        this.total = total;
      },
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
        this.pageSize = val;
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
        this.currentPage = val;
      },
      //退出
      close(){
        console.log('退出');
        Cookies.remove('token');
        this.$store.state.token = "";
        location.reload();
      }
    },
    created(){
      getOrg().then(res =>{
        console.log('当前机构信息',res);
        this.username = res.org_name
      })
    },
    computed: {
      // username() {
      //   return this.$store.state.user_name
      // }
    }
  }
</script>

<style>
  .el-table .el-table__cell{
    padding: 6px 0px;
  }
  .el-footer{
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 200px;
  }
  .el-pagination{
    padding: 0;
  }
  .el-header,.el-footer{
    background-color: #f7f7f7;
    color: #333;
    text-align: center;
    height: 60px;
    line-height: 0px;
    position: relative;
  }
  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 200px;
  }

  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    min-height: calc(100vh - 120px);
  }

  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }

  .el-dropdown-link {
    cursor: pointer;
    color: black;
  }

  .el-icon-arrow-down {
    font-size: 12px;
  }

  .demonstration {
    display: block;
    color: #8492a6;
    font-size: 14px;
    margin-bottom: 20px;
  }
</style>

<style scoped>
  .footer-content{
    font-size: 12px;
    color: black;
  }
  .el-icon-s-unfold {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    left: 10px;
    padding: 10px;
  }

  .el-icon-s-unfold:hover {
    background-color: white;
  }

  .el-icon-s-fold {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    left: 10px;
    padding: 10px;
  }

  .el-icon-s-fold:hover {
    background-color: white;
  }

  .user-name {
    color: black;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    right: 50px;
  }
</style>
